package servlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.Study;
import model.User;
import DAO.ParticipationDao;
import DAO.StudyDao;
import DAO.UserDao;

public class MemberPaymentAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		HttpSession session=request.getSession();
		ActionForward forward=new ActionForward();
		
		
		UserDao userDao = new UserDao();
		User user = new User();
	
		request.setAttribute("checkValue", "checkValue");
		int userId = session.getAttribute("userid") != null
				&& session.getAttribute("userid") != "" ? Integer
				.parseInt((String)session.getAttribute("userid")) : 0;
		String memId = session.getAttribute("memid") != null
					&& session.getAttribute("memid") != "" ? (String)session.getAttribute("memid") : null;
		if (userId < 1 ) {
			session.invalidate();
			Util.ShowError(response, "로그인해주세요");
		}
		
		int point = request.getParameter("point") != null 
				&& request.getParameter("point") !="" ? Integer.parseInt(request.getParameter("point")):0;
		
		
		userDao.chargePoint(memId, point);
		
		
		forward.setPath("./Payment.Member");
		return forward;

	}

}
